package com.gin.kotlin.no_gay_alliance.model

import android.os.Parcelable
import com.fasterxml.jackson.annotation.JsonIgnore
import com.gin.nga.enums.ForumType
import com.gin.nga.enums.status.ForumStatus
import com.gin.nga.response.topic.SubForum
import kotlinx.parcelize.Parcelize

/**
 * 子版面
 * @property type  版面类型
 * @property id  id
 * @property mirrorId  在 [635版](https://bbs.nga.cn/thread.php?fid=635) 的镜像贴id
 * @property bit  状态bit
 * @property name  名称
 * @property icon  图标
 * @constructor
 */
@Parcelize
data class SubForumModel(
    var type: ForumType? = null,
    var id: Long? = null,
    var mirrorId: Long? = null,
    var bit: Int? = null,
    var name: String? = null,
    var icon: String? = null,
) : Parcelable {
    constructor(subForum: SubForum) : this(
        type = subForum.type,
        id = subForum.id,
        mirrorId = subForum.mirrorId,
        bit = subForum.bit,
        name = subForum.name,
        icon = subForum.getBigIconUrl(),
    )
    /**
     * 版面状态
     * @return List<ForumStatus>?
     */
    @JsonIgnore
    fun getStatus() = ForumStatus.parse(bit!!)
    fun forumId() = if (type == ForumType.FORUM) id else null
    fun colTid() = if (type == ForumType.COL) id else null
}